﻿using System;
using System.Collections.Generic;
using MassSpectrum.dto;
using MassSpectrum.Model;


namespace MassSpectrum.Controller
{
    public class ProcessFactory
    {
        public static DataReader Reader = new DataReader();
        public static IDataWriter Writer = new DataWriter();
       
        public static string path =  DateTime.Now.ToString("dd/MM/yyyy HH-mm-ss") + ".txt";
        public static string oldpath = path;
/*
        public static void WriteDump()
        {
            Reader.WriteDump();
        }
 */
        public static bool GetConnection()
        {
           return Reader.GetConnection();
        }

        public static void StartMeashurement()
        {
            Reader.StartReading();
        }

        public static Data GetMeasurement()
        {
            return Reader.ReadData();
        }

        public static IList<Data> ReadFromFile(string path)
        {
            return Reader.ReadData(path);
        }

        public static void WriteMeasurement(IList<Data> data)
        {
            Writer.WriteData(data, path);
        }

        public static void WriteFile(string target)
        {
            Writer.WriteFile(oldpath, target);
          
        }

        public static void StopMeasurement()
        {
            Reader.CloseConnection();
        }
    }
}
